//go:build.sh js && wasm

package main

import (
	"syscall/js"
)

func main() {
	alert := js.Global().Get("alert")
	alert.Invoke("Hello from WebAssembly!")

	js.Global().Set("add", js.FuncOf(add))
	select {}
}

func add(this js.Value, args []js.Value) any {
	sum := args[0].Int() + args[1].Int()
	return js.ValueOf(sum)
}

//cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" .

//go run -v http.server 8080
